import axios from "../utils/axios";

//获取预约信息数据
const preinfoApi = async (_data: { page: number; size: number }) => {
  const data = await axios({
    url: "preinfo/findAll?page=" + _data.page + "&size=" + _data.size,
    method: "post",
  });
  return data;
};
//搜索预约信息带分页
const seachinfoApi = async (_data: {
  endTime?: string;
  page?: 1;
  preStatus?: number;
  query?: string;
  size?: 5;
  startTime?: string;
}) => {
  const data = await axios({
    url: "/preinfo/findLike",
    method: "post",
    data: _data,
  });
  return data;
};
//更改预约记录状态,与预约时间
const changeinfoApi = async (_data: {
  preinfoId?: string;
  status?: number;
  preTime?: string;
}) => {
  if (_data.preTime) {
    const data = await axios({
      url:
        "/preinfo/update?preinfoId=" +
        _data.preinfoId +
        "&preTime=" +
        _data.preTime,
      method: "get",
    });
    return data;
  } else {
    const data = await axios({
      url:
        "/preinfo/update?preinfoId=" +
        _data.preinfoId +
        "&status=" +
        _data.status,
      method: "get",
    });
    return data;
  }
};
//批量更改预约记录状态
const changeSinfoApi = async (_data: { preinfoIds?: any; status?: number }) => {
  const data = await axios({
    url: "/preinfo/updates?status=" + _data.status,
    method: "post",
    data: _data.preinfoIds,
  });
  return data;
};
export { preinfoApi, seachinfoApi, changeinfoApi, changeSinfoApi };
